package com.ebt.m.utils.android;

import com.ebt.m.data.middle.EBTGetAdviceInfo;
import com.ebt.m.exception.EBTException.EBTSoapHeaderException;

import org.apache.http.HttpException;
import org.apache.http.conn.ConnectTimeoutException;

import java.io.IOException;
import java.util.Map;

/***
 * 请求WS帮助类
 * @author ZhanWu.Li
 *
 */
public class WebServiceRequestHelper {
	
	/**
	 * 发送请求（没有用户信息时候发送请求）
	 * @param params
	 * @param wsdl
	 * @param soapAction
	 * @param method
	 * @param xmlnS
	 * @return
	 * @throws HttpException
	 * @throws EBTSoapHeaderException
	 * @throws IOException
	 * @throws Exception
	 */
	public static String sendRequestByNoAccount(Map params,String wsdl,String soapAction,String method,String  xmlnS) throws EBTSoapHeaderException, ConnectTimeoutException,Exception{
		
		
		String account = EBTGetAdviceInfo.getAppVersionName();
		String key = EBTGetAdviceInfo.getApkVersionKey();
		String keyJson = ProductDownloader.downloadSoapHeaderKey(account,key);
		String public_key=EBTUserInfoHelper.getUserkeyValue(keyJson);
		params.put("strUserId", "");
		params.put("strEquipment", EBTGetAdviceInfo.getDeviceInfo());
	
		SoapObject soapobjet= new SoapObject(xmlnS,account,public_key);
		soapobjet.setMethod(method);
		soapobjet.setParams(params);
		soapobjet.setWsURL(wsdl);
		soapobjet.setSoapAction(soapAction);
	
		
		return  soapobjet.sendRequest();
	}

}
